<?php
	include_once'../config/db.php';
	include_once'../functions/loginLib.php';
	
	if(isset($_SESSION['e_logged_in'])) header('location:index.php');
	
	if(isset($_REQUEST['login'])){
		$arr=array();
		if($_REQUEST['admin_user']!=='' || $_REQUEST['admin_pass']!==''){
			$funct=admin_mod($_REQUEST['admin_user'], $_REQUEST['admin_pass']);
			if(!empty($funct)){
				$_SESSION['admin_id']=$funct['admin_id'];
				$_SESSION['admin_user']=$funct['admin_user'];
				$_SESSION['admin_pass']=$funct['admin_pass'];
				$_SESSION['e_logged_in'] = 'logged_in';
				header('location: index.php');
			}
			else
				$invalid=TRUE;
			}
			else{
				$error=TRUE;
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../style.css" type="text/css"/>
<title>Untitled Document</title>
</head>

<body>
<div id="container">
<h3>Rizal Technological University</h3>
<div id="login">
<?php if(isset($error)):?>
<div id="error">You enter empty field</div>
<?php elseif(isset($invalid)):?>
<div id="error">Invalid Login</div>
<?php endif;?>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  <table width="384" border="0">
    <tr>
      <td width="55">&nbsp;</td>
      <td width="319"><input name="admin_user" type="text" id="admin_user" value="Admin Username" size="40" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="admin_pass" type="password" id="admin_pass" value="Admin Password" size="40" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="login" type="submit" class="blue" id="login2" value="Admin Login" /></td>
    </tr>
</table>
</form>
</div></div>
<p>&nbsp;</p>
</body>
</html>